package com.zzz.gp.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: ZZZ
 * @time: 2021/2/24 14:07
 */
public enum ReturnCodeEnum {
    REQUEST_SUCCESS("0","请求成功"),
    REQUEST_FAIL("101","请求失败"),
    PARAMETER_ERROR("102","参数不正确"),
    QUERY_NO_RESULT("103","查询无结果");

    private static  Map<String,ReturnCodeEnum> map=new HashMap<String,ReturnCodeEnum>();
    static {
        for (ReturnCodeEnum returnCodeEnum:ReturnCodeEnum.values()){
            map.put(returnCodeEnum.getCode(),returnCodeEnum);
        }
    }

    public static ReturnCodeEnum getReturnCodeEnumByCode(String code){
          return map.getOrDefault(code,ReturnCodeEnum.REQUEST_FAIL);
    }

    private String code;
    private String message;

    ReturnCodeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static Map<String, ReturnCodeEnum> getMap() {
        return map;
    }

    public static void setMap(Map<String, ReturnCodeEnum> map) {
        ReturnCodeEnum.map = map;
    }
}
